/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 石方旭
 * Date: 2022-04-15
 * Time: 10:56
 */
public class TestDemo {

    public static void main(String[] args) {
        //数字转字符串
        int a = 10;

    }


    public static void main4(String[] args) {
       String str = "Hello,programmer";
        System.out.println(str.lastIndexOf('p'));//从字符串最后位置开始找字符p
        System.out.println(str.lastIndexOf("pro"));//从字符串最后位置开始找字符串pro
        System.out.println(str.lastIndexOf('p',14));//从14的位置往前找字符p
        System.out.println(str.lastIndexOf("pro",4));//从4位置往前找字符串pro
        System.out.println(str.lastIndexOf("pr",10000));//超出范围就会从最后位置寻找
    }


    public static void main3(String[] args) {
        String str1 = "hello";
        String str2 = "hello";
        String str3 = new String("hello");
        String str4 = new String("hello");
        String str5 = "world";
        System.out.println(str1.equals(str2));
        System.out.println(str1.equals(str3));
        System.out.println(str3.equals(str4));
        System.out.println(str3.equals(str5));
    }

    public static void main2(String[] args) {
        String str1 = "hello";
        String str2 = new String("world");
        char[] chars = {'c','s','d','n'};
        String str3 = new String(chars);//将字符数组组装成字符串
        //String str3 = (String)chars;//将字符数组组装成字符串
        System.out.println(str3);
    }

    public static void main1(String[] args) {
        String s1="abc"+"def";//1
        String s2=new String(s1);//2
        if(s1.equals(s2))//3
            System.out.println(".equals succeeded");//4
        if(s1==s2)//5
            System.out.println("==succeeded");//6
    }

}
